/*
 * wall.cpp
 *
 *  Created on: Mar 19, 2012
 *      Author: Michael Ziminsky
 */

Wall::Wall(const vector3 &p, scalar l, bool vert) :
                RigidBody(p, "0 0 0", 0, 0), _length(l), _vertical(vert)
{

}

scalar Wall::length() const
{
        return _length;
}

void Wall::length(scalar l)
{
        _length = l;
}

bool Wall::isVertical() const
{
        return _vertical;
}

void Wall::isVertical(bool v)
{
        _vertical = v;
}

vector3 Wall::doGetSupport(const vector3 &v) const
{
        vector3 end(_position);
        if (_vertical) end[1] += _length;
        else end[0] += _length;

        if (arma::dot(end, v) > arma::dot(_position, v))
                return end;
        else
                return _position;
}

void Wall::integrate(scalar) {}
